import request from '@/utils/request.js'

// 用户注册请求
export const userRegisterService = async ({ username, password, repassword }) =>
  await request.post('/api/reg', { username, password, repassword })

// 用户登录请求
export const userLoginService = async ({ username, password }) =>
  request.post('/api/login', { username, password })

// 获取用户信息请求
export const userGetInfoService = () => request.get('/my/userinfo')

// 修改基本资料请求
export const userHandleInfoService = data => request.put('/my/userinfo', data)

// 更换用户头像
export const userUpdateAvatarServce = avatar =>
  request.patch('/my/update/avatar', { avatar })

// 更新用户密码
export const userUpdatePassword = (old_pwd, new_pwd, re_pwd) =>
  request.patch('/my/updatepwd', { old_pwd, new_pwd, re_pwd })
